{include file="public/header"}
<link rel="stylesheet" href="__PUBLIC__/home/js/drop/dropload.css">
<script src="__PUBLIC__/home/js/drop/dropload.min.js"></script>
<script src="__PUBLIC__/home/js/echarts.min.js"></script>
<style type="text/css">
body{background:#E6FDCD;}
	.footer1 .p1{
		margin-top:1px;font-weight: bold;
	}
</style>


<body>
<div class="bg_fixed_v10_2"></div>
<div class="sectionY sectionY_tttt" style="position: inherit">
	<p class="p1" style="color: #fff">
		<span class="ppp_title">交易</span>
	</p>
	<a href="{:url('Rent/order')}" class="a3">订单</a>
</div>
<div class="uzi_section1">
	<div class="container">
		<div class="uzi_section1_1">
			<div class="top clearfix">
				<div class="left">
					<p class="p1">{$day_info.day_price|default='--'}</p>
					<p class="p2">今日行情(CNY)</p>
				</div>
				<div class="right">
					<p class="p1">
						<span class="s1">{$day_info.bonus|default='--'}</span>
						<span class="s2">周周分红(SCB)</span>
					</p>
					<p class="p1">
						<span class="s1">{$day_info.qiugou|default='--'}</span>
						<span class="s2">总求购量(SCB)</span>
					</p>
					<p class="p1">
						<span class="s1">{$day_info.deal|default='--'}</span>
						<span class="s2">总成交量(SCB)</span>
					</p>
				</div>
			</div>
			<div class="buttom">
				<div id="main" style="height: 12rem;margin-top: 5px;"></div>
			</div>
		</div>
	</div>
</div>
<div class="uzi_section2">
	<div class="container">
		<div class="uzi_section2_1 clearfix">
			<div class="a1">
				<img src="__PUBLIC__/home/images/v10_a21.png" alt="">
				<span class="s1">交易时间：早9:00-晚21:00</span>
			</div>
			<div class="a2">
				<a href="{:url('Set/orderPublish')}">
					<img src="__PUBLIC__/home/images/v10_a22.png" alt="">
					<span class="s1">发布求购</span>
				</a>
			</div>
		</div>
	</div>
</div>
<div class="uzi_section3 content">
	<div class="container content1">
<!--		<div class="list clearfix">-->
<!--			<div class="left">-->
<!--				<p class="p1">求购数量：10 BOT</p>-->
<!--				<p class="p2">币种单价：15.8456 CNY</p>-->
<!--			</div>-->
<!--			<div class="right">-->
<!--				<a href="">出售</a>-->
<!--			</div>-->
<!--		</div>-->
<!--		<div class="list clearfix">-->
<!--			<div class="left">-->
<!--				<p class="p1">求购数量：10 BOT</p>-->
<!--				<p class="p2">币种单价：15.8456 CNY</p>-->
<!--			</div>-->
<!--			<div class="right">-->
<!--				<a href="">出售</a>-->
<!--			</div>-->
<!--		</div>-->
<!--		<div class="list clearfix">-->
<!--			<div class="left">-->
<!--				<p class="p1">求购数量：10 BOT</p>-->
<!--				<p class="p2">币种单价：15.8456 CNY</p>-->
<!--			</div>-->
<!--			<div class="right">-->
<!--				<a href="">出售</a>-->
<!--			</div>-->
<!--		</div>-->
	</div>
</div>
<!--v10 弹窗-->
<div class="v10_alert" style="display: none">
	<div class="v10_alert_1">
		<div class="v10_alert1_title">
			<p class="p1">提示</p>
		</div>
		<div class="v10_alert1_center">
			<p class="p1">&nbsp;</p>
			<p class="p1">&nbsp;</p>
			<p class="p1">确定要出售吗？</p>
		</div>
		<div class="v10_alert1_last">
			<a href="javascript:;" class="" onclick="sure_sell(this)">确定</a>
			<a href="javascript:;" class="" onclick="$('.v10_alert').hide()">取消</a>
		</div>
	</div>
</div>
<div class="kong"></div>
{include file="public/newfoot"}
</body>
	<script type="text/javascript">
	// 基于准备好的dom，初始化echarts实例
	var myChart = echarts.init(document.getElementById('main'));
	// 指定图表的配置项和数据
	var option = {
		xAxis: {
			type: 'category',
			data: {$day_list},
			axisLine: {
				lineStyle: {
					color: '#fff', // 颜色
					width: 1 // 粗细
				},
				interval: 1
			},
			axisLabel:{
				interval:0
			}
		},
		yAxis: {
			type: 'value',
			splitNumber : 5,
			axisLine: {
				lineStyle: {
					color: '#fff', // 颜色
					width: 1 // 粗细
				}
			}
		},
		series: [{
			data: {$price_list},
			type: 'line',
			symbol: 'circle',
			symbolSize: 8,
			itemStyle : {
				normal : {
					color:'#04c5f0', //改变折线点的颜色
					lineStyle:{
						color:'#04c5f0' //改变折线颜色
					}
				}
			}

		}],
		grid:{
			x:25,
			y:25,
			x2:15,
			y2:35,
			borderWidth:1
		},

	};
	// 使用刚指定的配置项和数据显示图表。
	myChart.setOption(option);
</script>
<script>
	$(function(){
		// 页数
		var page = 0;
		// 每页展示10个
		var page_size = 10;
		// dropload
		$('.content').dropload({
			scrollArea : window,
			domUp : {
				domClass   : 'dropload-up',
				domRefresh : '<div class="dropload-refresh" style="color: #fff">↓下拉刷新</div>',
				domUpdate  : '<div class="dropload-update" style="color: #fff">↑释放更新</div>',
				domLoad    : '<div class="dropload-load" style="color: #fff"><span class="loading"></span>加载中</div>'
			},
			domDown : {
				domClass   : 'dropload-down',
				domRefresh : '<div class="dropload-refresh" style="color: #fff">↑上拉加载更多</div>',
				domLoad    : '<div class="dropload-load" style="color: #fff"><span class="loading"></span>加载中</div>',
				domNoData  : '<div class="dropload-noData" style="color: #fff">暂无更多交易数据</div>'
			},
			loadUpFn : function(me){
				page=1;
				var _html = '';
				$.ajax({
					url:'{:url("User/loadTrade")}',
					data:{
						page:page,
						page_size:10
					},
					dataType:"JSON",
					type:"GET",
					success:function (res){
						var data = res.result_data;
						if(data.length>0){
							_html = formatList(data);
						}
						$('.content1').html(_html);
						// 每次数据加载完，必须重置
						me.resetload();
						// 重置页数，重新获取loadDownFn的数据
						page = 1;
						// 解锁loadDownFn里锁定的情况
						me.unlock();
						me.noData(false);
					},
					error:function (res){
						alert(res);
					}
				})
			},
			loadDownFn : function(me){
				page++;
				var _html = '';
				$.ajax({
					url:'{:url("User/loadTrade")}',
					data:{
						page:page,
						page_size:10
					},
					dataType:"JSON",
					type:"GET",
					success:function (res){
						var data = res.result_data;
						if(data.length>0){
							_html = formatList(data);
						}else{
							// 锁定
							me.lock();
							// 无数据
							me.noData();
						}
						// 插入数据到页面，放到最后面
						$('.content1').append(_html);
						// 每次数据插入，必须重置
						me.resetload();
					},
					error:function (res){
						alert(res);
					}
				})
			},
			threshold : 50
		});
	});

	function formatList(data){
		var _html = '';
		$.each(data, function (i,v){
			_html += '      <div class="list clearfix">' +
					'         <div class="left">' +
					'            <p class="p1">求购数量：'+v.num+' SCB</p>' +
					'            <p class="p2">币种单价：'+v.price+' CNY</p>' +
					'         </div>' +
					'         <div class="right">' +
					'            <a href="javascript:showSell('+v.id+');">出售</a>' +
					'         </div>' +
					'      </div>';
		})
		return _html
	}
	
	function showSell(id) {
		$(".v10_alert").data('order_id', id).show();
	}
	
	function sure_sell(o) {
		var order_id = $(".v10_alert").data('order_id');
		$.ajax({
			url:"{:url('sureSell')}",
			data:{
				order_id
			},
			dataType:"json",
			type:"post",
			success:function (res) {
				layer.msg(res.result_info);
				if(res.result_code == 0){
					$(".v10_alert").hide();
					setTimeout(function (){
						location.href = "{:url('Rent/order', ['type'=>2])}"
					}, 888)
				}
			},
			error:function () {

			}
		})

	}
</script>
</html>
